<?php

$string = '<countries><country name="Vietnam">
  <field rel="f2147">
     <subfield name="total" />100
     <subfield name="population" />500
  </field>
</country>
<country name="Laos">
  <field rel="f2147">
     <subfield name="total" /> 50
  </field>
</country></countries>';

$xml = simplexml_load_string(trim($string));

echo '<pre>' .print_r($xml, true) . '</pre>';



echo $xml->country->attributes()->name;
echo '<br />this is text in field tag: ' .  (string)$xml->country->field;
echo '<br />this is text in sub field tag: ' .  print_r($xml->country->field->subfield, true);
echo '<pre>' .print_r($xml->country->field->children(), true) . '</pre>';
echo $xml->country->field->subfield->attributes()->name;
echo '<pre>' .print_r($xml->country->attributes()->name, true) . '</pre>';